<%-- 
    Document   : register_background
    Created on : 12 Jan, 2013, 7:43:08 PM
    Author     : s
--%>
 
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%@include file="connection.jsp" %>
<%@page import="java.sql.*" %>


<%!
String f_nm,l_nm,e_mail,pass,pack,mo_no,but,id;
Date dt;
long time;

%>
 
<%
    but=(String)request.getParameter("submit");
    id=(String)request.getParameter("id");
     f_nm=(String)request.getParameter("f_nm");
        l_nm=(String)request.getParameter("l_nm");
        e_mail=(String)request.getParameter("email");
        pass=(String)request.getParameter("pass");
        mo_no=(String)request.getParameter("mo_no");
        pack=(String)request.getParameter("package");
        time=System.currentTimeMillis();
        dt=new Date(time);
    if(but.equals("ADD"))
    {
       
    
        pstmt=con.prepareStatement("insert into user values(NULL,?,?,?,DES_ENCRYPT(?),?,?,?)");
        pstmt.setString(1, e_mail);
        pstmt.setString(2, f_nm);
        pstmt.setString(3, l_nm);
        pstmt.setString(4, pass);
        pstmt.setString(5, mo_no);
        pstmt.setString(6, pack);
        pstmt.setDate(7, dt);
        pstmt.executeUpdate();
        pstmt.close();
            
        response.sendRedirect("admin_users.jsp?msg='User Added Successfully'");
     }
    if(but.equals("UPDATE"))
    {
        
        pstmt=con.prepareStatement("update user set e_mail=?,f_name=?,l_name=?,password=DES_ENCRYPT(?),mo_no=?,pac_id=?,sub_dt=? where sr_no="+id+"");
        pstmt.setString(1, e_mail);
        pstmt.setString(2, f_nm);
        pstmt.setString(3, l_nm);
        pstmt.setString(4, pass);
        pstmt.setString(5, mo_no);
        pstmt.setString(6, pack);
        pstmt.setDate(7, dt);
        pstmt.executeUpdate();
        pstmt.close();
         response.sendRedirect("admin_users.jsp?msg='User Updated Successfully'");
    }
%>
